package com.xt.mvcpilot.service.impl;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.xt.core.exception.ObjectCanNotSaveException;
import com.xt.core.service.hibernate.BasicServiceImpl;

import com.xt.mvcpilot.dao.AppBasicDao;
import com.xt.mvcpilot.data.AppBasicDBObject;
import com.xt.mvcpilot.data.User;
import com.xt.mvcpilot.service.AppBasicService;

/**
 * Generic Manager in hibernate implementaion that talks to BasicDao to CRUD POJOs.
 *
 * <p>Extend this interface if you want typesafe (no casting necessary) managers
 * for your domain objects.
 *
 * <p>Extended the GenericManagerImpl from generic Service framework
 *
 * @author txiao
 * @version Revision: 1.0, Date: 27.06.2011
 * @param <T> a type variable
 * @param <PK> the primary key for that type
 */
public class AppBasicServiceImpl<T, PK extends Serializable> 
	extends BasicServiceImpl<T, PK> implements AppBasicService<T, PK>{
	 
	protected AppBasicDao<T, PK> basicDao;
	
	public AppBasicServiceImpl() {
		super();
	}
	
	public AppBasicServiceImpl(AppBasicDao<T, PK> basicDao) {
		super(basicDao);
		this.basicDao = basicDao;
	}
	
	/**
	 * 
	 * 
	 */
	@Transactional(propagation=Propagation.REQUIRED, readOnly=false)
	public void saveorupdate(T object, User currentUser) throws ObjectCanNotSaveException{
		AppBasicDBObject o = (AppBasicDBObject) object;
		saveorupdate(object);
	}
}
